#!/usr/bin/perl -w

# extrack.pl - script for Perl. It's intended for extracting only one track from standard input and
# printing it to standard output.

# USAGE:
# ./base/scripts/extrack.pl <track_id>
# track_id - the index of track to be extracted.

$cnt = 0;
$id = -1;
while($s = <STDIN>) {
	if ($cnt == 0) {
		$cnt = $s;
		$id++;
		if ($id > $ARGV[0]) {
			last;
		}
	} else {
		if ($id == $ARGV[0]) {
			print $s;
		}
		$cnt--;
	}
}
